<!DOCTYPE html>
<html lang="en">


{include file="Public/head"}

<body data-type="widgets">
<script src="/assets/js/theme.js"></script>
<div class="am-g tpl-g">

    {include file='Public:header'}
    {include file='Public:menu2'}



    <!-- 内容区域 -->
    <div class="tpl-content-wrapper">
        <div class="row-content am-cf">
            <div class="row">
                <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                    <div class="widget am-cf">
                        <div class="widget-head am-cf">
                            <div class="widget-title  am-cf">订单列表</div>
                        </div>
                        <div class="widget-body  am-fr">
                            <div class="row">
                                <div class="col-xs-12">
                                    <div class="box">
                                        <nav class="navbar navbar-default">
                                            <div class="collapse navbar-collapse">
                                                <div class="navbar-form pull-right margin">
                                                    <a href="{:url('edit')}?order_id={$order.order_id}" class="btn btn-primary" >修改订单</a>
                                                    <!--<a href="/index.php/admin/order/split_order/order_id/806" data-toggle="tooltip" title="" class="btn btn-primary" data-original-title="编辑">拆分订单</a>-->
                                                    <a href="{:url('printOrder')}?order_id={$order.order_id}" target="_blank" data-toggle="tooltip" title="" class="btn btn-primary" data-original-title="打印订单">
                                                    <i class="fa fa-print"></i>打印订单
                                                    </a>
                                                    <a  class="btn btn-primary" onclick="orderButton({$order.order_id},'order_status',5);">报废订单</a>
                                                    <a href="javascript:history.go(-1)" data-toggle="tooltip" title="" class="btn btn-default" data-original-title="返回"><i class="fa fa-reply"></i></a>
                                                </div>
                                            </div>
                                        </nav>

                                        <!--新订单列表 基本信息-->
                                        <div class="panel panel-default">
                                            <div class="panel-heading">
                                                <h3 class="panel-title text-center">基本信息</h3>
                                            </div>
                                            <div class="panel-body">
                                                <table class="table table-bordered">
                                                    <tbody>
                                                    <tr>
                                                        <td>订单 ID:</td>
                                                        <td>订单号:</td>
                                                        <td>订单类型:</td>
                                                        <td>会员:</td>
                                                        <td>电话:</td>
                                                        <td>应付:</td>
                                                        <td>订单 状态:</td>
                                                        <td>下单时间:</td>
                                                        <td>支付时间:</td>
                                                        <td>支付方式:</td>
                                                    </tr>
                                                    <tr>
                                                        <td>{$order.order_id}</td>
                                                        <td>{$order.order_sn}</td>
                                                        <td>{if $order.order_cal==1}加盟商{else}用户{/if}</td>
                                                        <td>{if $order.order_cal==1}
                                                            <a href="{:url('Member/add')}?user_id={$order.user_id}" target="_blank">{$user.name}</a>
                                                            {else}
                                                            <a href="{:url('Member/add')}?user_id={$order.user_id}" target="_blank">{$user.nickname}</a>
                                                            {/if}
                                                        </td>
                                                        <td>{$order.mobile}</td>
                                                        <td>{$order.order_amount}</td>
                                                        <td id="order-status">
                                                            {$status.order_status[$order.order_status]} /
                                                            {$status.pay_status[$order.pay_status]}/
                                                            {$status.shipping_status[$order.shipping_status]}
                                                        <td>{$order.add_time|date='Y-m-d H:i:s',###}</td>
                                                        <td>{if $order.pay_time==0}未支付{else}{$order.pay_time|date='Y-m-d H:i:s',###}{/if}</td>
                                                        <td id="pay-type">{$order.pay_name}</td>
                                                    </tr>

                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>
                                        <!--新订单列表 收货人信息-->
                                        <div class="panel panel-default">
                                            <div class="panel-heading">
                                                <h3 class="panel-title text-center">收货信息</h3>
                                            </div>
                                            <div class="panel-body">
                                                <table class="table table-bordered">
                                                    <tbody><tr>
                                                        <td>收货人:</td>
                                                        <td>联系方式:</td>
                                                        <td>地址:</td>
                                                        <td>邮编:</td>
                                                        <td>配送方式:</td>

                                                    </tr>
                                                    <tr>
                                                        <td>{$order.consignee}</td>
                                                        <td>{$order.mobile}</td>
                                                        <td>{$order.address}</td>
                                                        <td>{$order.zipcode}</td>
                                                        <td>{$order.shipping_name}</td>
                                                    </tr>
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>
                                        <!--新订单列表 商品信息-->
                                        <div class="panel panel-default">
                                            <div class="panel-heading">
                                                <h3 class="panel-title text-center">商品信息 </h3>
                                            </div>
                                            <div class="panel-body">
                                                <table class="table table-bordered">
                                                    <thead>
                                                    <tr>
                                                        <td class="text-left">商品</td>
                                                        <td class="text-left">属性</td>
                                                        <td class="text-right">数量</td>
                                                        <td class="text-right">单品价格</td>
                                                        <td class="text-right">单品小计</td>
                                                    </tr>
                                                    </thead>
                                                    <tbody>
                                                    {foreach name="$goods" key="k" item="v"}
                                                    <tr>
                                                        <td class="text-left"><a href="{:url('mobile/classify/goodsinfo')}?id={$v.goods_id}" target="_blank">{$v.goods_name}</a>{if $v.is_send==3}(已退货){elseif $v.is_send==2}(已换货){/if}</td>
                                                        <td class="text-left">{$v.spec_key_name}</td>
                                                        <td class="text-right">{$v.goods_num}</td>
                                                        <td class="text-right">{$v.goods_price}</td>
                                                        <td class="text-right">{$v.goods_price*$v.goods_num}</td>
                                                    </tr>
                                                    {/foreach}
                                                    <tr>
                                                        <td colspan="3" class="text-right">小计:</td>
                                                        <td class="text-right">{$order.goods_price}</td>
                                                    </tr>
                                                    </tbody>
                                                </table>

                                            </div>
                                        </div>
                                        <!--新订单列表 费用信息-->
                                        <div class="panel panel-default">
                                            <div class="panel-heading">
                                                {if $order.pay_status=="1"}
                                                <h3 class="panel-title text-center">费用信息(已付费不可修改)
                                                    <a class="btn btn-primary btn-xs" data-original-title="修改费用" title="" data-toggle="tooltip" >
                                                        <i class="fa fa-pencil"></i>
                                                    </a>
                                                </h3>
                                                {else /}
                                                <h3 class="panel-title text-center">费用信息
                                                    <a class="btn btn-primary btn-xs" data-original-title="修改费用" title="" data-toggle="tooltip" href="{:Url('editprice')}?order_id={$order.order_id}}">
                                                        <i class="fa fa-pencil"></i>
                                                    </a>
                                                </h3>
                                                {/if}

                                            </div>
                                            <div class="panel-body">
                                                <table class="table table-bordered">
                                                    <tbody>
                                                    <tr>
                                                        <td class="text-right">小计:</td>
                                                        <td class="text-right">会员折扣价:</td>
                                                        <td class="text-right">运费:</td>
                                                        <td class="text-right">优惠券抵扣</td>
                                                        <td class="text-right">价格调整:</td>
                                                        <td class="text-right">应付:</td>
                                                    </tr>
                                                    <tr>
                                                        <td class="text-right">{$order.goods_price}</td>
                                                        <td class="text-right">{$order.total_amount}</td>
                                                        <td class="text-right">{$order.shipping_price}</td>
                                                        <td class="text-right">{$order.coupon_price}</td>
                                                        <td class="text-right">{$order.discount}</td>
                                                        <td class="text-right">{$order.order_amount}</td>
                                                    </tr>
                                                    </tbody>
                                                </table>

                                            </div>
                                        </div>
                                        <!--新订单列表 操作记录信息-->
                                        <div class="panel panel-default">
                                            <div class="panel-heading">
                                                <h3 class="panel-title text-center">操作信息{if $order.order_status==5||$order.order_status==4}(已取消或已作废的订单不可操作-){/if}</h3>
                                            </div>
                                            <!--已取消或已作废的订单不可操作-->
                                            {if $order.order_status!=5&&$order.order_status!=3}


                                            <div class="panel-body">
                                                <div class="row">
                                                </div><div class="row">
                                            </div><table class="table table-bordered">
                                                <tbody>
                                                <tr>
                                                    <td class="text-right col-sm-2"><p class="margin">操作备注：</p></td>
                                                    <td colspan="3">
                                                        <form form="submit">
                                                            <textarea name="note" placeholder="请输入操作备注" rows="3" class="form-control"></textarea>
                                                        </form>
                                                    </td>

                                                </tr>
                                                <tr>
                                                    <td class="text-right col-sm-2"><p class="margin">当前可执行操作：</p></td>
                                                    <td colspan="3">
                                                        <div class="input-group">

                                                            {foreach name="orderButton" key="k" item="v"}
                                                            {if $v.order_field=="shipping_status"}
                                                            <a href="{:url('Orderdelivery/add')}?order_id={$order.order_id}"><button class="btn btn-primary margin">{$v.button_name}</button></a>
                                                            {else /}
                                                            <button class="btn btn-primary margin" onclick="orderButton({$order.order_id},'{$v.order_field}',{$v.field_val});" type="button" id="confirm">
                                                                {$v.button_name}
                                                            </button>
                                                            {/if}

                                                            {/foreach}
                                                        </div>
                                                    </td>

                                                </tr>
                                                </tbody>
                                            </table>
                                            </div>
                                            {/if}
                                        </div>
                                        <!--新订单列表 操作信息-->
                                        <div class="panel panel-default">
                                            <div class="panel-heading">
                                                <h3 class="panel-title text-center">操作记录</h3>
                                            </div>
                                            <div class="panel-body">
                                                <table class="table table-bordered">
                                                    <thead>
                                                    <tr>
                                                        <td class="text-center">操作者</td>
                                                        <td class="text-center">操作时间</td>
                                                        <td class="text-center">订单状态</td>
                                                        <td class="text-center">付款状态</td>
                                                        <td class="text-center">发货状态</td>
                                                        <td class="text-center">描述</td>
                                                        <td class="text-center">备注</td>
                                                    </tr>
                                                    </thead>
                                                    <tbody>
                                                    {foreach name='orderAction' key="k" item="v"}
                                                        <tr>
                                                            <td class="text-center">{$v.user_name}</td>
                                                            <td class="text-center">{$v.log_time|date='Y-m-d H:i:s',###}</td>
                                                            <td class="text-center">{$status.order_status[$v.order_status]}</td>
                                                            <td class="text-center">{$status.pay_status[$v.pay_status]}</td>
                                                            <td class="text-center">{$status.shipping_status[$v.shipping_status]}</td>
                                                            <td class="text-center">{$v.status_desc}</td>
                                                            <td class="text-center">{$v.action_note}</td>
                                                        </tr>
                                                    {/foreach}
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>


                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>

</body>
{include file='Public:script'}
<link href="/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css">
<script src="/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="/daterangepicker/daterangepicker.js" type="text/javascript"></script>

<script>
    // 删除按钮
    function del_button(id, className) {
        layer.confirm("确定删除？", {btn: ["确定","取消"], shade: 0.5}, function(){
            // 删除权限组
            $.post("{:url('del')}", {id: id}, function(res) {
                if (res.code != 200) {
                    layer.msg(res.msg, {shade: 0.5, time: 1000, icon: 2});
                    return false;
                }

                layer.msg(res.msg, {shade: 0.5, time: 1000, icon: 1}, function() {
                    layer.closeAll('page');
                    location.reload();
                });
            });
        }, function () {});
    }

    //提交
    function roleSubmit() {
        var form = document.getElementById("searchform");
        var formData = new FormData(form);
        $.ajax({
            url: "{:Url('index')}",
            type: 'POST',
            data: formData,
            async: false,
            cache: false,
            contentType: false, //不设置内容类型
            processData: false, //不处理数据
            success: function (res) {
                console.log(res);
                if (res.code != 200) {
                    layer.msg(res.msg, {shade: 0.5, time: 2000, icon: 2});
                    return false;
                }
                layer.msg(res.msg, {shade: 0.5, time: 2000, icon: 1}, function () {
                    window.location.href = document.referrer;

                });
            }
        })
    }

    //选择时间js
    $(document).ready(function() {
        $('#start_time').daterangepicker({
            format:"YYYY-MM-DD",
            singleDatePicker: false,
            showDropdowns: true,
            minDate:'2016-01-01',
            maxDate:'2030-01-01',
            startDate:'2016-01-01',
            showWeekNumbers: true,
            timePicker: false,
            timePickerIncrement: 1,
            timePicker12Hour: true,
            ranges: {
                '今天': [moment(), moment()],
                '昨天': [moment().subtract('days', 1), moment().subtract('days', 1)],
                '最近7天': [moment().subtract('days', 6), moment()],
                '最近30天': [moment().subtract('days', 29), moment()],
                '上一个月': [moment().subtract('month', 1).startOf('month'), moment().subtract('month', 1).endOf('month')]
            },
            opens: 'right',
            buttonClasses: ['btn btn-default'],
            applyClass: 'btn-small btn-primary',
            cancelClass: 'btn-small',
            locale : {
                applyLabel : '确定',
                cancelLabel : '取消',
                fromLabel : '起始时间',
                toLabel : '结束时间',
                customRangeLabel : '自定义',
                daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
                monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月','七月', '八月', '九月', '十月', '十一月', '十二月' ],
                firstDay : 1
            }
        });
    });

    //订单操作按钮      (订单id    字段           值
    function orderButton($order_id,$order_field,$field_val){
       $note= $('[name="note"]').val();//备注
        $.post("{:url('setOrder')}", {order_id: $order_id,order_field:$order_field,field_val:$field_val,note: $note}, function(res) {
            if (res.code != 200) {
                layer.msg(res.msg, {shade: 0.5, time: 1000, icon: 2});
                return false;
            }
            layer.msg(res.msg, {shade: 0.5, time: 1000, icon: 1}, function() {
                layer.closeAll('page');

                location.reload();//刷新
            });
        });
    }
</script>
</html>